package view;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

@SuppressWarnings("serial")
public class PanelAddTeacher extends JPanel {

	private static PanelAddTeacher single;

	private JTextField JTname = new JTextField();
	private JTextField JTcode = new JTextField();

	private JButton add = new JButton("Opslaan");
	private JButton cancel = new JButton("Annuleren");

	private JLabel JLname = new JLabel("Naam docent: ");
	private JLabel JLcode = new JLabel("Code docent: ");

	private PanelAddTeacher() {
		setLayout(null);
		setBounds(0, 0, 860, 720);

		add(PanelSelector.addTitle("Docent:"));

		JTname.setBounds(400, 150, 140, 30);
		JTcode.setBounds(400, 200, 140, 30);
		JLname.setBounds(260, 150, 140, 30);
		JLcode.setBounds(260, 200, 140, 30);
		add.setBounds(200, 500, 140, 30);

		add.addActionListener(new controller.AddTeacher(this));

		cancel.setBounds(500, 500, 140, 30);

		cancel.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				PanelHolder mf = PanelHolder.getInstance();
				mf.remove(PanelAddTeacher.getInstance());
				mf.add(PanelTeacherList.getInstance());
				mf.repaint();
				mf.validate();
			}
		});

		add(JTcode);
		add(JLcode);
		add(JLname);

		add(JTname);
		add(add);
		add(cancel);

	}

	public Object getActionField() {

		return null;
	}

	public JTextField getJTname() {
		return JTname;
	}

	public void setJTname(JTextField jTname) {
		JTname = jTname;
	}

	public JTextField getJTcode() {
		return JTcode;
	}

	public void setJTcode(JTextField jTcode) {
		JTcode = jTcode;
	}

	public static PanelAddTeacher getInstance() {
		if (single == null) {
			single = new PanelAddTeacher();
		}
		return single;
	}

	public void selfDestroy() {
		single = null;
	}

	public static PanelAddTeacher getSingle() {
		return single;
	}

	public static void setSingle(PanelAddTeacher single) {
		PanelAddTeacher.single = single;
	}

	public JButton getAdd() {
		return add;
	}

	public void setAdd(JButton add) {
		this.add = add;
	}

	public JButton getCancel() {
		return cancel;
	}

	public void setCancel(JButton cancel) {
		this.cancel = cancel;
	}

	public JLabel getJLname() {
		return JLname;
	}

	public void setJLname(JLabel jLname) {
		JLname = jLname;
	}

	public JLabel getJLcode() {
		return JLcode;
	}

	public void setJLcode(JLabel jLcode) {
		JLcode = jLcode;
	}

	public static Component newInstance() {
		single = new PanelAddTeacher();
		return single;
	}

}
